﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DialogWindow : Window
{
    [SerializeField]
    private Text playerName;
    [SerializeField]
    private Image playerAvatar;
    [SerializeField]
    private Text npcName;
    [SerializeField]
    private Image npcAvatar;
    [SerializeField]
    private GameObject npcDialogArea, npcQuestArea,questPrefab, ButtonOne,ButtonTwo,ButtonThree;
    private QuestGiver questGiver;
    
    public override void Open(npc nPC)
    {
        //foreach (KeyValuePair<string, Dialog> kv in (nPC as QuestGiver).MyDialogDictionary.myDictionary)
        //{
        //    foreach (string sentence in kv.Value.MySentences)
        //    {
        //        
        //    }

        //}
       
        if (nPC.MyName != null)
        {
            npcName.text = nPC.MyName;
            
        }
        if (nPC.MyAvatar != null)
        {
            npcAvatar.sprite = nPC.MyAvatar;
            
        }
        if(Player.MyInstance.MyName != null)
        {
            playerName.text = Player.MyInstance.MyName;
            
        }
        if(Player.MyInstance.MyAvatar != null)
        {
            playerAvatar.sprite = Player.MyInstance.MyAvatar;
            
        }
        ButtonOne.SetActive(true);
        ButtonTwo.SetActive(true);
        ButtonThree.SetActive(true);
        ButtonOne.GetComponentInChildren<Text>().text = string.Format("1. Ani werk for me?");
        ButtonTwo.GetComponentInChildren<Text>().text = string.Format("2. Dost Thou know anī-thing about thas plāce?");
        ButtonThree.GetComponentInChildren<Text>().text = string.Format("3. Dont mind me, I was just passing bī");
        base.Open(nPC);

    }
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void ShowQuests(QuestGiver qg)
    {
        ButtonOne.SetActive(true);
        ButtonTwo.SetActive(true);
        ButtonThree.SetActive(false);
        npcQuestArea.SetActive(true);
        npcDialogArea.SetActive(false);

        this.questGiver = qg;
        foreach(Quest q in qg.MyQuests)
        {
            GameObject go = Instantiate(questPrefab, npcQuestArea.transform);
        }

    }
    public void DisplayQuests()
    {
        ShowQuests(questGiver);
    }
    private void ButtonSwitch(bool activeOne, bool activeTwo, bool activeThree, string textOne, string textTwo, string textThree)
    {
        //Change to alignment
    }
}
